<?php

namespace App\Admin\Controllers;

use App\Models\DailyReport;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class DailyReportController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '日报表';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new DailyReport);
        $grid->model()->orderBy('id','desc');

        $grid->column('id', __('Id'));
        $grid->column('date', __('日期'));
        $grid->column('active_ct', __('活跃人数'));
        $grid->column('register_ct', __('注册用户数'));
        $grid->column('classify_ct', __('选择分类继续人数'));
        $grid->column('un_book_ct', __('当日注册未选择书的人数'));
        $grid->column('mobile_ct', __('手机号授权人数'));
        $grid->column('fir_sub_click', __('首页订阅按钮点击人数'));
        $grid->column('fir_sub_sub', __('订阅人数'));
        $grid->column('one_sub_pop', __('订阅弹窗-10词触发人数'));
        $grid->column('one_sub_click', __('点击人数'));
        $grid->column('one_sub_sub', __('订阅人数'));
        $grid->column('two_sub_pop', __('订阅弹窗-20词触发人数'));
        $grid->column('tow_sub_click', __('点击人数'));
        $grid->column('two_sub_sub', __('订阅人数'));
        $grid->column('thr_sub_pop', __('订阅弹窗-30词触发人数'));
        $grid->column('thr_sub_click', __('点击人数'));
        $grid->column('thr_sub_sub', __('订阅人数'));
        //$grid->column('created_at', __('Created at'));
        //$grid->column('updated_at', __('Updated at'));
        $grid->disableActions();
        $grid->disableCreateButton();
        $grid->disableFilter();


        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(DailyReport::findOrFail($id));

        $show->field('id', __('Id'));
        $show->field('date', __('Date'));
        $show->field('fir_sub_click', __('Fir sub click'));
        $show->field('fir_sub_sub', __('Fir sub sub'));
        $show->field('one_sub_pop', __('One sub pop'));
        $show->field('one_sub_click', __('One sub click'));
        $show->field('one_sub_sub', __('One sub sub'));
        $show->field('two_sub_pop', __('Two sub pop'));
        $show->field('tow_sub_click', __('Tow sub click'));
        $show->field('two_sub_sub', __('Two sub sub'));
        $show->field('thr_sub_pop', __('Thr sub pop'));
        $show->field('thr_sub_click', __('Thr sub click'));
        $show->field('thr_sub_sub', __('Thr sub sub'));
        $show->field('created_at', __('Created at'));
        $show->field('updated_at', __('Updated at'));
        $show->field('register_ct', __('Register ct'));
        $show->field('mobile_ct', __('Mobile ct'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new DailyReport);

        $form->date('date', __('Date'))->default(date('Y-m-d'));
        $form->number('fir_sub_click', __('Fir sub click'))->default(1);
        $form->number('fir_sub_sub', __('Fir sub sub'))->default(1);
        $form->number('one_sub_pop', __('One sub pop'))->default(1);
        $form->number('one_sub_click', __('One sub click'))->default(1);
        $form->number('one_sub_sub', __('One sub sub'))->default(1);
        $form->number('two_sub_pop', __('Two sub pop'))->default(1);
        $form->number('tow_sub_click', __('Tow sub click'))->default(1);
        $form->number('two_sub_sub', __('Two sub sub'))->default(1);
        $form->number('thr_sub_pop', __('Thr sub pop'))->default(1);
        $form->number('thr_sub_click', __('Thr sub click'))->default(1);
        $form->number('thr_sub_sub', __('Thr sub sub'))->default(1);
        $form->number('register_ct', __('Register ct'))->default(1);
        $form->number('mobile_ct', __('Mobile ct'))->default(1);

        return $form;
    }
}
